(function(){
	@@include("./common/_menu.js")
	@@include("./common/_popWindow.js")
	//瀑布流
	$("img.lazy").lazyload({ 
        placeholder : "./images/images_4@2x.png",
        effect: "show",
        threshold :600
    });
	$(".infinite-scroll").infinitescroll({
		navSelector: ".recommend-more",
		nextSelector: ".recommend-more a",
		itemSelector: ".item",
		requestUrl: "./lib/recommend.json?type=home&categor_id=1&page=",	
		loading:{
			img: "images/masonry_loading_1.gif",
			msgText: ' ',
			finishedMsg: '',
			render: function(resData,opts){
				var data = "";
				try{
	                var temp = JSON.parse(resData);
	                if(temp.code == 200) {
	                    if(opts.state.currPage >= temp.data.last_page){
	                        opts.state.isFinished = true;
	                    }
	                    $.each(temp.data.data,function(i,item){
	                    	var price = item.current_price ? item.current_price : item.original_price;
	                    	data += '<div class="production-detail"><a href="" class="sub-channel"><h5 class="channel-title">Best CC Creams for Acne-Prone Skin</h5><i></i></a><div class="img-details"><a href=""><span class="img-show"><img class="lazy" data-original="./images/index/772422DC-5C9E-4E3C-8CD2-0CB7A6DB7582@2x.png"></span><p class="rank1">No.1</p><p class="name">Canon EOS-1D X Mark III</p><p class="price">$80</p></a><a href=""><span class="img-show"><img class="lazy" data-original="./images/index/AF84A7CD-6C9E-47A2-9821-05BBC9510A46@2x.png"></span><p class="rank2">No.2</p><p class="name">Canon EOS-1D X Mark III</p><p class="price">$80</p></a><a href=""><span class="img-show"><img class="lazy" data-original="./images/index/5F7C64CB-5A22-4370-9FB6-EBC268A3CDAC@2x.png"></span><p class="rank3">No.3</p><p class="name">Canon EOS-1D X Mark III</p><p class="price">$80</p></a></div></div>';
	                    })
	                }
	            }catch(e){}
	            return data;
			},
			finished: function(opts){
				if(opts.state.isFinished){ //结束事件
					$(".recommend-more").remove();
					$("#infscr-loading").hide();
					$(window).unbind('.infscr');
				}
			}	
		},errorCallback:function(res){ 
			console.log(res);
		}
		
	},function(newElements){
		var $newElems = $(newElements);
		$('.infinite-scroll').append($newElems);
		$newElems.fadeIn();
		//瀑布流
		$("img.lazy").lazyload({ 
	        placeholder : "./images/images_4@2x.png",
	        effect: "show",
	        threshold :600
	    });
		return;
	});
})()